// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick

import Fk

Item {
  id: root
  state: "5"
  width: 12
  height: 14
  readonly property string path: Cpp.path + "/packages/lunarltk-qsgs-ui/image/photo/magatamas/"

  Image {
    source: getSource(0)
    fillMode: Image.PreserveAspectFit
    opacity: main.opacity > 0 ? 0 : 1
    anchors.centerIn: parent
    height: root.height
  }

  states: [
    State {
      name: "5"
      PropertyChanges {
        target: main
        source: root.getSource(5)
        opacity: 1
        scale: 1
      }
    },
    State {
      name: "4"
      PropertyChanges {
        target: main
        source: root.getSource(4)
        opacity: 1
        scale: 1
      }
    },
    State {
      name: "3"
      PropertyChanges {
        target: main
        source: root.getSource(3)
        opacity: 1
        scale: 1
      }
    },
    State {
      name: "2"
      PropertyChanges {
        target: main
        source: root.getSource(2)
        opacity: 1
        scale: 1
      }
    },
    State {
      name: "1"
      PropertyChanges {
        target: main
        source: root.getSource(1)
        opacity: 1
        scale: 1
      }
    },
    State {
      name: "0"
      PropertyChanges {
        target: main
        source: root.getSource(0)
        opacity: 0
        scale: 4
      }
    }
  ]

  transitions: Transition {
    PropertyAnimation {
      properties: "opacity,scale"
    }
  }

  Image {
    id: main
    anchors.centerIn: parent
    height: root.height
    fillMode: Image.PreserveAspectFit
  }

  function getSource(idx) {
    if (Config.heg) {
      if (idx == 5 || idx == 4) {
        idx = 3;
      } else if (idx == 3) {
        idx = 2;
      }
      return SkinBank.magatamaDir + idx + '-heg';
    }
    return path + idx;
  }
}
